package com.medsoft.logpool.action;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.beanutils.BeanMap;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cyl.kernel.BaseController;
import com.cyl.kernel.InPacket;
import com.cyl.kernel.OutPacket;
import com.medsoft.logpool.core.AppLog;
import com.medsoft.logpool.core.LogService;


/**
 * Created with IntelliJ IDEA.
 * User: zjhua
 * Date: 2015-01-02
 * Time: 23:56
 * Mail: zjhua@hundsun.com
 * Comment: 功能描述
 * Modifiy History: 修改历史
 * To change this template use File | Settings | File Templates.
 */
@Controller
public class IndexAction extends LogpoolBaseController {
	
	@Autowired
	private LogService logService;
	
	@RequestMapping(value="/index.html",method=RequestMethod.GET)
	public void index(Model model,HttpServletRequest request){
		//NOP
	}
	
	@RequestMapping(value="/index.html",method=RequestMethod.POST)
	public void queryLog(@ModelAttribute("appLog") AppLog appLog,
			Model model,HttpServletRequest request){
		Map<String, String> param = new BeanMap(appLog);
		model.addAttribute("results", logService.queryLog(param));
	}
}
